package com.block.datapush.service.apipush.utils;

import cn.hutool.core.util.StrUtil;
import com.alibaba.druid.util.StringUtils;
import com.block.common.enums.BaseTypeInfoEnum;
import org.apache.commons.codec.binary.Base64;

import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;


/**
 * 众鑫
 */
public class XinHuaUtil {


    public static String getshebao(String shebao) {
        if (StrUtil.equals(BaseTypeInfoEnum.Shebao.sb001.getValue(), shebao)) {
            return "无";
        }
        return "有";
    }





    public static String getGjj(String gongjijin) {
        if (StrUtil.equals(BaseTypeInfoEnum.Gjj.gjj001.getValue(), gongjijin)) {
            return "无";
        }
        return "有";
    }

    public static String getyuqi(String yuqi) {
        if (StrUtil.equals(BaseTypeInfoEnum.Yuqi.yq001.getValue(), yuqi)) {
            return "无逾期记录";
        }
        return "有逾期记录";
    }


    public static String getCar(String car) {
        if (StrUtil.equals(BaseTypeInfoEnum.Car.car001.getValue(), car)) {
            return "无";
        }
        return "有";
    }


    public static String getHouse(String house) {
        if (StrUtil.equals(BaseTypeInfoEnum.House.hu001.getValue(), house)) {
            return "无";
        }
        return "有";
    }

    public static String getHuabei(String huabei) {
        if (StrUtil.equals(BaseTypeInfoEnum.Huabei.hb001.getValue(), huabei)) {
            return "无";
        }
        return "有";
    }
    public static String getBaitiao(String baitiao) {
        if (StrUtil.equals(BaseTypeInfoEnum.Baitiao.bt001.getValue(), baitiao)) {
            return "无";
        }
        return "有";
    }


    public static String getbaodan(String baodan) {
        if (StrUtil.equals(BaseTypeInfoEnum.Baoxian.bx001.getValue(), baodan)) {
            return "无";
        }
        return "有";
    }


    public static String getloan(String loan) {
        if (StrUtil.equals(BaseTypeInfoEnum.LoanAmount.la001.getValue(), loan)) {
            return "3万";
        } else if (StrUtil.equals(BaseTypeInfoEnum.LoanAmount.la002.getValue(), loan)) {
            return "5万";
        } else if (StrUtil.equals(BaseTypeInfoEnum.LoanAmount.la003.getValue(), loan)) {
            return "10万";
        } else if (StrUtil.equals(BaseTypeInfoEnum.LoanAmount.la004.getValue(), loan)) {
            return "20万";
        }
        return "25万";

    }


    public static String getZhimaScore(String zhima) {
        if (StrUtil.equals(BaseTypeInfoEnum.Zhima.zm005.getValue(), zhima)) {
            return "700以上";
        } else if (StrUtil.equals(BaseTypeInfoEnum.Zhima.zm004.getValue(), zhima)) {
            return "650-699";
        } else if (StrUtil.equals(BaseTypeInfoEnum.Zhima.zm003.getValue(), zhima)) {
            return "600-649";
        }
        return "0-599";
    }


    public static String getLoanTime(String loanTime) {
        if(StrUtil.equals(BaseTypeInfoEnum.LoanTime.lt001.getValue(), loanTime)){
            return "3";
        }
        return "6";
    }

    public static String getShouRu(String shouru) {
        if(StrUtil.equals(BaseTypeInfoEnum.Shouru.sr001.getValue(), shouru)){
            return "2000";
        }else if(StrUtil.equals(BaseTypeInfoEnum.Shouru.sr002.getValue(), shouru)){
            return "5000";
        }else if(StrUtil.equals(BaseTypeInfoEnum.Shouru.sr003.getValue(), shouru)){
            return "10000";
        }
        return "15000";
    }

    public static String getXinYongKa(String xinyongka) {
        if(StrUtil.equals(BaseTypeInfoEnum.XinYongKa.xyk001.getValue(), xinyongka)){
            return "无";
        }
        return "有";
    }

    public static String getXueli(String xueli) {
        if(StrUtil.equals(BaseTypeInfoEnum.XueLi.xl002.getValue(), xueli) || StrUtil.equals(BaseTypeInfoEnum.XueLi.xl001.getValue(), xueli)){
            return "初中及以下";
        }else if(StrUtil.equals(BaseTypeInfoEnum.XueLi.xl003.getValue(), xueli)){
            return "专科";
        }else if(StrUtil.equals(BaseTypeInfoEnum.XueLi.xl004.getValue(), xueli)){
            return "本科";
        }
        return "研究生";
    }

    public static String getJob(String gongzuo) {
        if(StrUtil.equals(BaseTypeInfoEnum.Gongzuo.gz001.getValue(), gongzuo)){
            return "上班族";
        }else  if(StrUtil.equals(BaseTypeInfoEnum.Gongzuo.gz002.getValue(), gongzuo)){
            return "私营企业主";
        }else  if(StrUtil.equals(BaseTypeInfoEnum.Gongzuo.gz004.getValue(), gongzuo)){
            return "公务员/国企";
        }
        return "自由职业";
    }



    public static String encrypt(String contentStr, String key) {
        try {
            if(StringUtils.isEmpty(contentStr)) {
                return null;
            }
            byte[] raw = key.getBytes(StandardCharsets.UTF_8);
            SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
            Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
            cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
            byte[] encrypted = cipher.doFinal(contentStr.getBytes(StandardCharsets.UTF_8));
            return new Base64().encodeToString(encrypted);
        } catch(Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
